package altfee.example;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

public class TestMotionView extends View {

	private Paint 	mPaint  = new Paint();
	private int 	mAction;
	private float 	mX;
	private float 	mY;
	public TestMotionView(Context context) {
		super(context);
		mAction = MotionEvent.ACTION_UP;
		mX 		= 0;
		mY 		= 0;
	}
	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		//super.onDraw(canvas);
		canvas.drawColor(Color.WHITE);
		if(mAction == MotionEvent.ACTION_MOVE){
			mPaint.setColor(Color.RED);
		}
		else if(mAction == MotionEvent.ACTION_DOWN){
			mPaint.setColor(Color.GREEN);
		}
		else if(mAction == MotionEvent.ACTION_UP){
			mPaint.setColor(Color.BLUE);
		}
		canvas.drawCircle(mX, mY, 10, mPaint);
		//SetTitle("A = " + mAction + " ["+ mX + "," + mY + "]");
	}
	
	private static final String TAG = "tag";
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub
		mAction = event.getAction();
		mX		= event.getX();
		mY		= event.getY();
		Log.v(TAG, "Action = " + mAction);
		Log.v(TAG, "mX = " + mX + ", mY = " + mY);
		invalidate();
		return true;
		//return super.onTouchEvent(event);
	}
	
	
}